﻿using System;
using System.Runtime.InteropServices;


namespace advadev.Windows.CustomWindows.WindowsGDI
{

    /// <summary>
    /// Represents the dll imports
    /// </summary>
    static internal class DLLIMPORTS
    {

        /// <summary>
        /// Retrieves a handle to the top-level window whose class name and
        /// window name match the specified strings
        /// </summary>
        /// <param name="lpClassName">
        /// The class name or a class atom created by a previous call to the
        /// RegisterClass or RegisterClassEx function. The atom must be in the
        /// low-order word of lpClassName; the high-order word must be zero
        /// </param>
        /// <param name="lpWindowName">
        /// The window name (the window's title). If this parameter is NULL, all
        /// window names match
        /// </param>
        /// <returns>
        /// If the function succeeds, the return value is a handle to the window
        /// that has the specified class name and window name. If the function
        /// fails, the return value is NULL
        /// </returns>
        [DllImport("User32")]
        static internal extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        /// <summary>
        /// The GetMonitorInfo function retrieves information about a display
        /// monitor
        /// </summary>
        /// <param name="hMonitor">
        /// A handle to the display monitor of interest
        /// </param>
        /// <param name="lpmi">
        /// A pointer to a MONITORINFO or MONITORINFOEX structure that receives
        /// information about the specified display monitor
        /// </param>
        /// <returns>
        /// If the function succeeds, the return value is nonzero. If the
        /// function fails, the return value is zero
        /// </returns>
        [DllImport("User32")]
        static internal extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);

        /// <summary>
        /// The MonitorFromWindow function retrieves a handle to the display
        /// monitor that has the largest area of intersection with the bounding
        /// rectangle of a specified window
        /// </summary>
        /// <param name="hwnd">
        /// A handle to the window of interest
        /// </param>
        /// <param name="dwFlags">
        /// Determines the function's return value if the window does not
        /// intersect any display monitor. This parameter can be one of the
        /// following values:
        /// - MONITOR_DEFAULTTONEAREST
        /// - MONITOR_DEFAULTTONULL
        /// - MONITOR_DEFAULTTOPRIMARY
        /// </param>
        /// <returns>
        /// If the window intersects one or more display monitor rectangles, the
        /// return value is an HMONITOR handle to the display monitor that has
        /// the largest area of intersection with the window. If the window does
        /// not intersect a display monitor, the return value depends on the
        /// value of dwFlags
        /// </returns>
        [DllImport("User32")]
        static internal extern IntPtr MonitorFromWindow(IntPtr hwnd, int dwFlags);

        /// <summary>
        /// Sends the specified message to a window or windows
        /// </summary>
        /// <param name="hWnd">
        /// A handle to the window whose window procedure will receive the
        /// message
        /// </param>
        /// <param name="Msg">
        /// The message to be sent:
        /// - ...
        /// - WM_SYSCOMMAND
        /// - ...
        /// </param>
        /// <param name="wParam">
        /// Additional message-specific information
        /// </param>
        /// <param name="lParam">
        /// Additional message-specific information
        /// </param>
        /// <returns>
        /// The return value specifies the result of the message processing; it
        /// depends on the message sent
        /// </returns>
        [DllImport("User32")]
        static internal extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

        /// <summary>
        /// Sends an appbar message to the system
        /// </summary>
        /// <param name="dwMessage">
        /// Appbar message value to send. This parameter can be one of the
        /// following values:
        /// - ABM_NEW
        /// - ABM_REMOVE
        /// - ABM_QUERYPOS
        /// - ABM_SETPOS
        /// - ABM_GETSTATE
        /// - ABM_GETTASKBARPOS
        /// - ABM_ACTIVATE
        /// - ABM_GETAUTOHIDEBAR
        /// - ABM_SETAUTOHIDEBAR
        /// - ABM_WINDOWPOSCHANGED
        /// - ABM_SETSTATE
        /// </param>
        /// <param name="pData">
        /// A pointer to an APPBARDATA structure. The content of the structure
        /// on entry and on exit depends on the value set in the dwMessage
        /// parameter
        /// </param>
        /// <returns>
        /// This function returns a message-dependent value
        /// </returns>
        [DllImport("SHELL32")]
        public static extern int SHAppBarMessage(int dwMessage, ref APPBARDATA pData);

    }

}
